<template>
  <div class="layout-pd">
    <zh-card title="查询条件" v-if="pageData.showType">
      <zh-form :model="pageData.queryParams" ref="queryFormRef" label-width="160px" :span="8">
        <template v-if="pageData.advanced">
        </template>
        <zh-form-query v-model="pageData.advanced" :tableRef="queryTable" :formRef="queryFormRef"> </zh-form-query>
      </zh-form>
    </zh-card>
    <zh-table title="查询结果" ref="queryTable" size="mini" funcCode="eduHouseHoldOffline0001" :columns="pageData.tableColumns" highlight-current-row>
      <template #header_button>
        <zh-button button-type="add" @click="showAdd()" v-func:eduHouseHoldOffline0004>新增</zh-button>
      </template>
      <template #flag_default="{ row }">
        <zh-badge :status="statusMap[row.status].status" :text="statusMap[row.status].text" />
      </template>
      <template #operate="{ row }">
        <zh-button v-func:eduHouseHoldOffline0002 link @click="showdetail(row, true)" style="color: green">查看</zh-button>
        <zh-button v-func:eduHouseHoldOffline0005 link @click="showdetail(row, false)">修改</zh-button>
        <zh-button v-func:eduHouseHoldOffline0006 link @click="deleteData(row)" style="color: red">删除</zh-button>
      </template>
    </zh-table>

    <zh-dialog style="width: 80%" :title="pageData.title" v-model="pageData.detailVisible">
      <eduHouseHoldOfflineForm
          ref="menuRef"
          :disabled="pageData.editFlag"
          @canner="canner"
          @refreshTable="refreshTable"
          :householdId="pageData.selectRow.householdId"
      ></eduHouseHoldOfflineForm>
      <template #footer>
				<span class="dialog-footer">
					<zh-button @click="pageData.detailVisible = false">关闭</zh-button>
					<zh-button
              type="primary"
              :loading="pageData.saveLoading"
              :disabled="pageData.saveLoading"
              v-model:btnLoding="pageData.saveLoading"
              @click="save"
          >
						保存
					</zh-button>
				</span>
      </template>
    </zh-dialog>
  </div>
</template>
<script lang="ts" setup name="eduHouseHoldOfflineIndex">
import { ElMessageBox, ElMessage } from 'element-plus';
import eduHouseHoldOfflineForm from './component/eduHouseHoldOfflineForm.vue';

// ------------------接收传入参数(组件)-------------------

// ------------------钩子函数----------------------------
// 初始化
onMounted(() => {
  init();
});

// ------------------定义子组件--------------------------
const queryTable = ref();
const queryFormRef = ref();
const menuRef = ref();

const statusMap = {
  0: {
    status: 'error',
    text: '无效',
  },
  1: {
    status: 'processing',
    text: '有效',
  },
};

// ------------------变量区------------------------------
const pageData = reactive({
  advanced: false,

  tableColumns: [
    {
      type: 'seq',
      minWidth: 60,
      fixed: 'left',
      align: 'center',
      title: '序号',
    },
    {
      field: 'householdId',
      title: '主键',
      visible: false,
      align: 'center',
      minWidth: 80,
    },
    {
      field: 'hhid',
      title: '户号内部id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hh',
      title: '户号',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'contractor',
      title: '承办人',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'ryzt',
      title: '人员状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'ryid',
      title: '人员id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'idcard',
      title: '公民身份证件编码',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'fullName',
      title: '姓名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'beforeName',
      title: '曾用名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'height',
      title: '身高',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'birthday',
      title: '出生日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'birthplace',
      title: '出生地',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'sex',
      title: '性别',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'country',
      title: '国家',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'nation',
      title: '民族',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'nativePlace',
      title: '籍贯',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'addressCity',
      title: '户口所在地县市',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'addressCountry',
      title: '户口所在乡镇街道',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'addressVillage',
      title: '户口所在村社区',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'addressVillageDetail',
      title: '户口所在地街路巷',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'mlxz',
      title: '户口所在地门楼详址:mlxz和mlph只有其中一个',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'mlph',
      title: '户口所在地门楼牌号:mlxz和mlph只有其中一个',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'address',
      title: '户口所在完整地址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'addressId',
      title: '关联地址id',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householdPlace',
      title: '户籍所在地',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'street',
      title: '所属街道',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'maritalStatus',
      title: '婚姻状况',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'culturalLevel',
      title: '文化程度',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'religion',
      title: '宗教信仰',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'bloodType',
      title: '血型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'veteranTatus',
      title: '兵役状况',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householderIdcard',
      title: '户主身份证',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'householder',
      title: '户主姓名',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'accountType',
      title: '户口类型',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'relation',
      title: '与户主关系',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'pcs',
      title: '户口登记公安机关编码',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'registrationDate',
      title: '登记日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'registrationAuthority',
      title: '登记机关',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'qfjg',
      title: '签发机关',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hssqlbz',
      title: '何省市迁来本址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hssqxqlws',
      title: '何县区来本市',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hxzlbd',
      title: '何详址来本址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hsqlbs',
      title: '何时迁来本市',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'hsqlbz',
      title: '何时迁来本址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'cityOtherAddress',
      title: '本市(县)其他地址',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'serviceSpaces',
      title: '服务处所',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'number',
      title: '编号',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'tongTime',
      title: '数据归集日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'primarySchoolOne',
      title: '可就读小学顺位1',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'primarySchoolTwo',
      title: '可就读小学顺位2',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'primarySchoolThree',
      title: '可就读小学顺位3',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'primarySchoolFour',
      title: '可就读小学顺位4',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'juniorSchoolOne',
      title: '可就读初中顺位1',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'juniorSchoolTwo',
      title: '可就读初中顺位2',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'juniorSchoolThree',
      title: '可就读初中顺位3',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'juniorSchoolFour',
      title: '可就读初中顺位4',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'qysj',
      title: '启用时间',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'xxqysj',
      title: '迁移时间',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'yxqxqsrq',
      title: '有效期起始日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'yxqxjzrq',
      title: '有效期截止日期',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'jlbz',
      title: '记录标志',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'year',
      title: '年份',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'authStatus',
      title: '审核状态',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'status',
      title: '是否启用0.禁用1.启用',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'areaCode',
      title: '行政区划',
      visible: true,
      align: 'center',
      minWidth: 150,
    },
    {
      field: 'operate',
      title: '操作',
      fixed: 'right',
      align: 'center',
      minWidth: 210,
      slots: {
        // 使用插槽模板渲染
        default: 'operate',
      },
    },
  ],
  queryParams: {} as any,
  dictData: {} as any,
  title: '',
  detailVisible: false,
  editFlag: false,
  selectRow: {} as any,
  saveLoading: false,
  showType: true,
  campusParam: {} as any,
});
// ------------------方法区------------------------------
const init = () => {
  getDict();
  refreshTable();
};
// 查询数据字典信息
const getDict = () => {
  const params = {} as any;
  params.dictFields = '';
  $api.common.getBatchDict.post(params).then((res) => {
    pageData.dictData = res.result;
  });
};

//使用子组件方法，关闭弹窗
const canner = (e: any) => {
  pageData.detailVisible = e;
};

const showAdd = () => {
  pageData.title = '新增';
  pageData.detailVisible = true;
  pageData.editFlag = false;
  pageData.selectRow = {};
};

const showdetail = (row, flag) => {
  if (!flag) {
    pageData.title = '信息修改';
  } else {
    pageData.title = '查看详情';
  }
  pageData.selectRow = row;
  pageData.editFlag = flag;
  pageData.detailVisible = true;
};
//保存
const save = () => {
  menuRef.value.saveBase();
};

//刷新
const refreshTable = () => {
  queryTable.value.refresh(pageData.queryParams);
};
//删除
const deleteData = (row) => {
  ElMessageBox.confirm('是否确认删除？').then(() => {
    let params = {} as any;
    params.householdId = row.householdId;
    $api.common.send.post('eduHouseHoldOffline0006', params).then(() => {
      ElMessage.success('删除成功');
      refreshTable();
    });
  });
};

</script>
<style lang="scss" scoped></style>
